window.onload = function () {
    // 从后端获取当前用户角色列表（示例用 /me/roles 端点）
    fetch("/me/roles")
        .then(res => res.json())
        .then(roles => {
            // 只加载有权限的文档
            const urls = roles.map(role => ({
                name: role.toUpperCase(),
                url: `/v3/api-docs/${role.toLowerCase()}`
            }));
            window.ui = SwaggerUIBundle({
                urls: urls,
                dom_id: '#swagger-ui',
                presets: [SwaggerUIBundle.presets.apis]
            });
        });
};
